package com.fanrenqiji.modules.sys.entity;

import com.fanrenqiji.common.persistence.DataEntity;
import org.hibernate.validator.constraints.Length;

import javax.persistence.*;
import java.util.Date;

@Entity
@Table(name = "sys_notify_record")
public class NotifyRecord extends DataEntity {
	// 主键 订单编号
	private Long id;
	private Notify notify; // 通知通告ID
	private User user; // 接受人
	private String readFlag; // 阅读标记（0：未读；1：已读）
	private Date readDate; // 阅读时间
	
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public NotifyRecord() {
		super();
	}

	public NotifyRecord(Notify notify) {
		this.notify = notify;
	}

	@ManyToOne
	@JoinColumn(name = "notify_id")
	public Notify getNotify() {
		return notify;
	}

	public void setNotify(Notify notify) {
		this.notify = notify;
	}

	@ManyToOne
	@JoinColumn(name = "user_id")
	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	@Column(name = "read_flag")
	@Length(min = 0, max = 1, message = "阅读标记（0：未读；1：已读）长度必须介于 0 和 1 之间")
	public String getReadFlag() {
		return readFlag;
	}

	public void setReadFlag(String readFlag) {
		this.readFlag = readFlag;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "read_date")
	public Date getReadDate() {
		return readDate;
	}

	public void setReadDate(Date readDate) {
		this.readDate = readDate;
	}

}
